<%@ page language="java" 
	contentType="text/html; 
	charset=UTF-8"
	pageEncoding="UTF-8"
	import="connectMysql.TestConnect"
	%>
<!DOCTYPE html>
<!--验证两次密码是否相等  --> 
<!--验证电话号码是否是11位  -->
<!--验证该用户名是否已经存在  -->
<!--将 账号 姓名 密码 用户类型 插入user_table中 -->
<html>

	<head>
	<meta charset="UTF-8">
	<title>注册账号</title>
	</head>	
	<body>
	<%
		String warning="";
		String redirectPage="login.jsp";
		String userID=request.getParameter("userID");
		String username = new String(request.getParameter("username").getBytes("ISO-8859-1"), "UTF-8");
		String psw=request.getParameter("password");
		String confirm=request.getParameter("confirm");
		String tel=request.getParameter("tel");
		String type=request.getParameter("type");
		boolean res_name=connectMysql.TestConnect.check_user_exist(userID,type);//账号存在true
		out.print(psw);
		if(res_name)
			warning="账号已存在！";
		else if(!psw.equals(confirm))
			warning="两次密码不一致！";
		else if(!tel.matches("\\d{11}"))
			warning="电话号码格式错误！";
		else {
			warning=username+"注册成功！";
			connectMysql.TestConnect.insert_user(userID, username, tel, psw,type);
			redirectPage="main.jsp?id="+userID;
		}
	%>
	<%=psw %>
	<%=confirm %>
	<%=tel %>
	<script>
		alert("<%= warning %>");
	    window.location.href = "<%= redirectPage %>";
	</script>
	</body>
</html>